package com.ssy.lingxi.order.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 订单合同
 * @author 万宁
 * @version 2.0.0
 * @date 2021-07-16
 */
@Entity
@Table(schema = "public", name = "ord_contract", indexes = {@Index(name = "ord_contract_order_id_idx", columnList = "order_id")})
public class OrderContractDO implements Serializable {
    private static final long serialVersionUID = 2174681397836652035L;

    /**
     * 主键Id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ord_contract_seq")
    @SequenceGenerator(sequenceName = "ord_contract_seq", name = "ord_contract_seq", allocationSize = 1)
    private Long id;

    /**
     * 一对一双向关联订单
     */
    @JsonBackReference
    @OneToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name="order_id", referencedColumnName="id")
    private OrderDO order;

    /**
     * 合同Id
     */
    @Column
    private Long contractId;

    /**
     * 合同编号
     */
    @Column(columnDefinition = "varchar(30)")
    private String contractNo;

    /**
     * 合同摘要
     */
    @Column(columnDefinition = "varchar(50)")
    private String digest;

    /**
     * 合同生效日期
     */
    @Column(columnDefinition = "timestamp")
    private LocalDateTime effectDate;

    /**
     * 合同失效日期
     */
    @Column(columnDefinition = "timestamp")
    private LocalDateTime expireDate;

    /**
     * 合同乙方
     */
    @Column(columnDefinition = "varchar(200)")
    private String partB;

    /**
     * 合同寻源类型，定义在 ContractSourceTypeEnum， 0-所有类型，1-采购询价，2-采购招标，3-采购竞价
     */
    @Column
    private Integer contractType;

    /**
     * 合同剩余金额
     */
    @Column(columnDefinition = "numeric")
    private BigDecimal leftAmount;

    /**
     * 对应单据
     */
    @Column(columnDefinition = "varchar(30)")
    private String receiptNo;

    /**
     * 合同文件名称
     */
    @Column(columnDefinition = "varchar(255)")
    private String fileName;

    /**
     * 合同文件Url
     */
    @Column(columnDefinition = "varchar(400)")
    private String url;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public OrderDO getOrder() {
        return order;
    }

    public void setOrder(OrderDO order) {
        this.order = order;
    }

    public Long getContractId() {
        return contractId;
    }

    public void setContractId(Long contractId) {
        this.contractId = contractId;
    }

    public String getContractNo() {
        return contractNo;
    }

    public void setContractNo(String contractNo) {
        this.contractNo = contractNo;
    }

    public String getDigest() {
        return digest;
    }

    public void setDigest(String digest) {
        this.digest = digest;
    }

    public LocalDateTime getEffectDate() {
        return effectDate;
    }

    public void setEffectDate(LocalDateTime effectDate) {
        this.effectDate = effectDate;
    }

    public LocalDateTime getExpireDate() {
        return expireDate;
    }

    public void setExpireDate(LocalDateTime expireDate) {
        this.expireDate = expireDate;
    }

    public String getPartB() {
        return partB;
    }

    public void setPartB(String partB) {
        this.partB = partB;
    }

    public Integer getContractType() {
        return contractType;
    }

    public void setContractType(Integer contractType) {
        this.contractType = contractType;
    }

    public BigDecimal getLeftAmount() {
        return leftAmount;
    }

    public void setLeftAmount(BigDecimal leftAmount) {
        this.leftAmount = leftAmount;
    }

    public String getReceiptNo() {
        return receiptNo;
    }

    public void setReceiptNo(String receiptNo) {
        this.receiptNo = receiptNo;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }
}
